import java.util.*;
public class Main {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        while (q-- != 0) {
            int num = in.nextInt();
            char[] ch = String.valueOf(num).toCharArray();

            if (num % 2 == 0) {
                System.out.println(num);
                continue;
            }

//            //将数字改为字符串
//            StringBuilder s = new StringBuilder();
//            while (num != 0) {
//                s.append(num % 10);
//                num /= 10;
//            }
//
//            char[] ch = s.toString().toCharArray();
            int len = ch.length;
            int i = 0;
            boolean flag = false;
            for (; i < len; i++) {
                int tem = ch[i] - '0';
                if (tem % 2 == 0) {
                    flag = true;
                    break;
                }
            }
            //判断
            if (flag) {
                char t = ch[0];
                ch[0] = ch[i];
                ch[i] = t;
                for (int j = len - 1; j >= 0; j--) System.out.print(ch[j] - '0');
                System.out.println();
            } else System.out.println(-1);

        }
    }
}

/**
 * 游游的重组偶数
 * https://www.nowcoder.com/questionTerminal/d1ac7f15d5dc40b39a7d6cb11a01407e
 */
 class Main1_2 {
    public static void swap(char[] s,int i,int j){
        char t = s[i];
        s[i] = s[j];
        s[j] = t;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        while (q-- != 0) {
            char[] s = in.next().toCharArray();
            int n = s.length;

            boolean flag = false;
            for(int i = n -1;i >= 0;i--){
                if((s[i] - '0') % 2 == 0){
                    flag = true;
                    swap(s,i,n-1);
                    break;
                }
            }
            if(flag){
                System.out.println(s);
            }else{
                System.out.println(-1);
            }
        }
    }
}

/**
 * 体操队形
 * https://ac.nowcoder.com/acm/problem/229386
 */


class Main2{
    static int n,ret;
    static int[] arr = new int[15];
    static boolean[] vis = new boolean[15];

    public static void dfs(int pos){

        if(pos == n + 1) {
            ret++;
            return;
        }


        int i = 1;
        for(;i <= n;i++){
            if(vis[i] == true) continue;//标记过的不需要再遍历
            //当前位置的诉求没有满
            if(vis[arr[i]]) break;
            vis[i] = true;
            dfs(pos + 1);//递归
            vis[i] = false;//回溯
        }
    }
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        n = in.nextInt();
        for(int i = 1;i <=n;i++) arr[i] = in.nextInt();

        dfs(1);

        System.out.println(ret);
    }
}
/**
 * 二叉树最大路劲和
 * https://www.nowcoder.com/practice/da785ea0f64b442488c125b441a4ba4a?tpId=196&tqId=37050&ru=/exam/oj
 */

 class Solution {

     static class TreeNode{
         TreeNode left;
         TreeNode right;
         int val;

         public TreeNode(int val){
             this.val = val;
         }
     }

    int ret = -1010;

    public int maxPathSum (TreeNode root) {
        dfs(root);
        return ret;
    }

    public int dfs(TreeNode root) {
        if (root == null) return 0;

        //获取左子树的最大单链和
        int left = Math.max(0, dfs(root.left));

        //获取右子树的最大单链和
        int right = Math.max(0, dfs(root.right));

        //经过root的最大路径和
        ret = Math.max(ret,root.val + left + right);

        //返回最大单链和
        return root.val + Math.max(left,right);
    }

     public static void main(String[] args) {
         TreeNode root = new TreeNode(1);
         TreeNode left = new TreeNode(2);
         root.left = left;

         Solution solution  = new Solution();
         System.out.println(solution.maxPathSum(root));
     }
}